<template>
  <el-container class="box">
    <el-header >
      <Tabs :userName="userName"/>
    </el-header>
    <HeaderTop :flag="true"/>
    <div class="Carousel">
      <el-carousel :interval="5000" arrow="always" >
        <el-carousel-item v-for="item in srcArr" :key="item">
          <img width="100%" height="100%" :src="item" alt="">
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="main">
      <div class="menu-left">
        <Menu></Menu>
      </div>
      <div class="center">
        <div class="center-box" v-for="(items,index) in data" :key="index">
          <el-row>
            <p>水果类</p>
            <div class="divider divider-border divider-center"><i data-v-4efabc7f="" class="fa fa-users"></i></div>
          </el-row>
          <el-row>
            <el-col class="appppp"  :span="6" v-for="(item, index) in items" :key="index" :offset="index > 0 ? 2 : 0">
              <div  @click="target(item)" >
                <el-card  :body-style="{ padding: '0px' }">
                  <img :src="item.img" class="image">
                  <div style="padding: 5px 14px 5px ;">
                    <div class="bottom clearfix">
                      <h4>{{item.text}}</h4>
                    </div>
                      <div class="text">
                        <span class="text1">￥{{item.oldPrice}}</span>
                        <span class="text2">￥{{item.newPrice}}</span>
                      </div>
                  </div>
                </el-card>
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
      <div class="right">
      </div>
    </div>
  </el-container>
</template>

<script>
import HeaderTop from './HeaderTop/HeaderTop.vue'
import Menu from './Menu/Menu.vue'
import data from './data.json'
import Tabs from './Tabs/Tabs.vue'
export default {
  components: { HeaderTop, Menu, Tabs },
  name: 'Home',
  data() {
    return {
      srcArr:[
        '../../static/images/backgrounds/bg1-min.jpg',
        '../../static/images/backgrounds/bg2-min.jpg',
        '../../static/images/backgrounds/blue.jpg',
        '../../static/images/backgrounds/default.jpg',
      ],
      activeName: '用户名',
      data,
      userName:''
    }
  },
  methods:{
    target(item){
      let { img,newPrice,oldPrice,text} = item
      console.log(text)
      this.$router.push('/product')
    },
    handleCommand(command){
      if(command === 'outUser'){
        this.$router.push('/login')
      }
    }
  },
  mounted(){
    let name =  localStorage.getItem('userName')
    this.userName = name
  }
}
</script>

<style scoped>
  .Carousel{
    width: 100%;
    height: 300px;
    margin-bottom: 60px;
  }
  .el-tabs{
    float: right;
    line-height: 61px;
    height: 61px;
  }
  .el-carousel{
    width: 80%;
    margin: 30px auto 0px;
  }
  .main{
    display: flex;
    justify-content: space-between;
  }
  .menu-left{
    width: 20%;
    border-right: 1px solid #bfa;
  }
  .el-card{
    position: relative;
    min-height: 342px;
  }

  .center{
    width: 60%;
  }
  .center-box{
    margin-bottom: 60px;
  }
  .divider{
    width: 92%;
  }
  .image{
    width: 100%;
  }
  .right{
    width: 10%;
  }
  .text{
    position: absolute;
    bottom: 0px;
    left: 25%;
    text-align: center;

  }
  .text1{
    color: #999;
    text-decoration: line-through;
  }
</style>
